<template>
    <div class="content">
        <div class="MapUp" ref="allmap"></div>
    </div>
</template>

<script>

    export default {
        name: "MapUp",
        mounted() {
            this.addMasker(0,0)
        },
        methods:{
            addMasker(m,n){
                let map = new BMap.Map(this.$refs.allmap);
                let myGeo = new BMap.Geocoder();
                let selected = this.$store.state.address;
                let title = this.$store.state.name;
                myGeo.getPoint(selected, function (point) {
                    if (point) {
                        map.centerAndZoom(point,15);
                        let marker = new BMap.Marker(point);
                        map.addOverlay(marker);

                        var opts = {
                            width: 250,
                            height: 60,
                            title: title,
                        };
                        var infoWindow = new BMap.InfoWindow("欢迎您",opts);
                        map.openInfoWindow(infoWindow, map.getCenter());
                    } else {
                        console.log('找不到地址')
                    }
                })
            }
        }
    }
</script>

<style scoped>
.content{
    position:absolute;
    top:0;
    left:0;
    right:0;
    bottom:0;
    background:#fff;
    z-index:100;
}
.MapUp{
    position:relative;
    top:0;
    left:0;
    right:0;
    bottom:.6rem;
    z-index:11111;
    height:60%;
}
</style>